Skip to content

SOLR-17697 Ref-guide documentation for new picocli commands#4271

Merged
janhoy merged 14 commits into
apache:jira/SOLR-17697-picoclifrom
janhoy:feature/picocli-cli-docs-generation
May 15, 2026
Merged

SOLR-17697 Ref-guide documentation for new picocli commands#4271
janhoy merged 14 commits into
apache:jira/SOLR-17697-picoclifrom
janhoy:feature/picocli-cli-docs-generation

Conversation

@janhoy
Copy link
Copy Markdown
Contributor

@janhoy janhoy commented Apr 8, 2026

This is a WIP POC for auto generating CLI ref-guide docs for the new picoCli instrumented tools. The docs are auto generated using PicoCLI's ManPageGenerator, one ref-guide page per tool. Menus are also updated, and tools are cross-linked. The existing landig page "Solr Control Script Reference" is reduced from a huge all-in-one page to an overview page that introduces the CLI and links to the generated man-pages. This way, our docs will always stay in sync with the actual @picocli annotations in the code.

There are two gradle tasks added in this PR:

  • generateCliDocs - Regenerate CLI reference pages in pages/cli/ from picocli annotations.
  • checkCliDocsUpToDate - Verify that pages/cli/ CLI docs are in sync with picocli annotations - runs on check

Screenshot:
Skjermbilde 2026-04-08 kl  12 12 01

This is a draft, mostly AI generated, not reviewed in full. Need discussion about how we want the docs to be.

https://issues.apache.org/jira/browse/SOLR-17697

@janhoy janhoy marked this pull request as draft April 8, 2026 10:25
@github-actions github-actions Bot added documentation Improvements or additions to documentation tool:build labels Apr 8, 2026
@janhoy janhoy requested review from dsmiley and epugh April 8, 2026 10:35
Comment thread solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-zk.adoc
Comment thread solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-start.adoc Outdated
// end::picocli-generated-man-section-commands[]

// tag::picocli-generated-man-section-exit-status[]
// end::picocli-generated-man-section-exit-status[]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could obviously add @picocli annotations to document exit status for all tools asl well... Not sure how useful it is. Guess for the assert tool it would be useful, and for the stop tool to signal success...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added example and exit-code documentation to the status tool. Here is how it looks:

Skjermbilde 2026-05-15 kl  12 08 25

== Command Reference

The table below lists all available `bin/solr` commands.
Commands marked with (✓) have dedicated reference pages auto-generated from source annotations; others are documented inline below.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is temporary, not intended for release. I suppose this entire "landing page" needs to be re-written in a way that gives a good overview, without touching the details.

Question: Currently we have usage examples hand written in the ref-guide page. We could instead add usage examples for each tool either in the description field or footer field, or some custom annotation that we invent and tie in when generating docs:

@Command(
    name = "myapp",
    footerHeading = "%nExamples:%n",
    footer = {
        "  # Basic usage",
        "  myapp --input foo.txt",
        "",
        "  # With options",
        "  myapp --input foo.txt --verbose"
    }
)

I think perhaps using footer for this purpose is a good approach, this way also the --help for each tool will print usage examples. I think we can sacrifice the current refguide URL link we have in all the footers. It can perhaps be included on the main bin/solr command only.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea. And the ref guide link is a bit of an oddity too anyway...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been caught many times with ref guide differences from reality in the docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I took a shot at generating (with LLM) usage examples for all the zk sub commands. See updated adoc pages. Example:

Skjermbilde 2026-05-15 kl  12 00 13

Comment thread solr/solr-ref-guide/build.gradle Outdated
@dsmiley
Copy link
Copy Markdown
Contributor

dsmiley commented Apr 8, 2026

This way, our docs will always stay in sync with the actual @picocli annotations in the code.

Nice!

@epugh
Copy link
Copy Markdown
Contributor

epugh commented Apr 8, 2026

I want to say how much i like the zk nesting of sub commands. I started hacking on a configset command in our old framework, and it was a bummer how hard it was to do nested subcommands. I can imaginge bin/solr configset upload -blah -blah and bin/solr configset putfile -blah -lbah and that nesting nicely in the docs with picocli!

janhoy added 4 commits May 15, 2026 12:08
…generation

# Conflicts:
#	solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java
#	solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java
#	solr/core/src/java/org/apache/solr/cli/StatusTool.java
#	solr/core/src/java/org/apache/solr/cli/UpdateACLTool.java
#	solr/core/src/java/org/apache/solr/cli/ZkLsTool.java
#	solr/core/src/java/org/apache/solr/cli/ZkRmTool.java
Remove some hacks in gradle
@janhoy
Copy link
Copy Markdown
Contributor Author

janhoy commented May 15, 2026

Note that the global options -Vand -h are now not included in each man page, much better (as a result of another PR that tailored the global options). I'll merge this into the feature branch any time now, and then we can continue iterating on that branch.

@janhoy janhoy marked this pull request as ready for review May 15, 2026 10:50
@janhoy janhoy merged commit f6d6f5f into apache:jira/SOLR-17697-picocli May 15, 2026
1 check passed
@janhoy janhoy deleted the feature/picocli-cli-docs-generation branch May 15, 2026 12:21
Comment thread dev-docs/ref-guide/antora.adoc

The only reason you will likely need to change the `antora.template.yml` is if you are introducing new variables for dependency versions.

== Auto-generated CLI Reference Pages
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it's funny what things we check into source code that are generated and what are not (SolrJ endpoints from OpenAPI annotations for example). I just ran the task to generate the cli pages and it went super fast.. What value are we getting by checking them into source code? I don't have a super strong opinon one way or the other, more of an observation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking them in gives less "magic" and will also help surface unintended CLI contract edites in tools as the PR will fail precommit, needing to re-generate docs. Then one can review if the change was intended and back-compat before calling generateCliDocs...

=== Adding docs for a new tool

The new command will automatically appear in the generated pages and the navigation when running `gradlew generateCliDocs`.
You will need to tie it in to the `solr-control-script-reference.adoc` yourself.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully we rework solr-control-script-reference.adoc.... I see the table you added flagging which have autogenerated links. At a minimum, we should eliminate the listing of parameters to each command that exist in solr-control-script-reference.adoc and lean into using the generated docs. I don't know if that is part of this PR or it's own?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the control-script-reference page has still more work to do. I'll add another check box in the feature-branch PR for it...

exitCodeListHeading = "%nExit Codes:%n",
exitCodeList = {
"0:Collection or core deleted successfully.",
"1:Failed to delete; collection or core may not exist, or Solr may not be running."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow... actual documentation of return codes! Helpful for folks writing automation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. Made me think about return codes a bit as well. Such as for solr stop. It will actually return 1 (failure) if solr was not already running. But perhaps it should be differentiated to returning

  • 0 if solr was running and successfully stopped
  • 1 if solr was not running
  • 2 if there was a syntax error in the command
  • 3 if solr was running but we could not stop it

This is out of scope for this PR, but I'd love it if documenting exit codes in picocli would lead to other PRs to clean up in our exit code behavior...

},
footerHeading = "%nExamples:%n",
footer = {
" # Create a collection in SolrCloud mode",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need to litter in SolrCloud mode everywhere? Or... Create a collection in SolrCloud mode and a core in User Managed mode? (sigh)...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder..... Should we introduce a bin/solr core create -c myCore and keep bin/solr create -c myCollection as solr cloud? are there use cases where folks want to work with a specific core while in solr cloud mode? This is a bit off topic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the createTool is also for standalone. So this should probably be fixed.

I was impatient and mergd doc branch into feature branch. So will include this in a fixup commit shortly

@CommandLine.Command(name = "start", description = "Starts Solr in standalone or SolrCloud mode.")
@CommandLine.Command(
name = "start",
description = "Starts Solr in standalone or SolrCloud mode.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standalone --> user-managed ? the switch is --user-managed. I dislike the term user managed, but it is what we agreed...... "Disagree and commit' ;-)

Copy link
Copy Markdown
Contributor Author

@janhoy janhoy May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in followup commit to feature branch. I also caught a bug in the last example, where Claude had constructed this impossible command:

# Start in standalone mode with an external ZooKeeper
bin/solr start --user-managed -z localhost:2181/solr

HAHA - user managed with zookeeper 🤣

Comment thread solr/solr-ref-guide/modules/deployment-guide/deployment-nav.adoc
Comment thread solr/solr-ref-guide/build.gradle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:cli documentation Improvements or additions to documentation tool:build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants